package org.apache.solr.handler.dataimport;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * {@link DocBuilder}
 * 包装，只为在在处理完成时，可以得到处理处理的数据（存储在session中的COLLECT_DELTA中）。
 * 
 * @author Gex
 *
 */
public class RecordableDocBuilder extends DocBuilder {

	public static final String COLLECT_DELTA = "COLLECT_DELTA";

	public RecordableDocBuilder(DataImporter dataImporter, DIHWriter solrWriter, DIHProperties propWriter,
			RequestInfo reqParams) {
		super(dataImporter, solrWriter, propWriter, reqParams);
	}

	@Override
	public Set<Map<String, Object>> collectDelta(EntityProcessorWrapper epw, VariableResolver resolver,
			Set<Map<String, Object>> deletedRows) {
		Set<Map<String, Object>> delta = super.collectDelta(epw, resolver, deletedRows);
		session.put(COLLECT_DELTA, new HashSet<>(delta));
		return delta;
	}

}
